

from django.db.models import Sum
from decimal import Decimal
from django.db.models import Q, F
import requests
import json
import datetime
from apps.common.utils.decrypt import *
from apps.merchant.item.dao import ItemDao
from apps.merchant.sku.dao import SkuDao
from apps.interface.client.dao import ClientDao
from apps.system.user.dao import UserDao
from apps.pay.order.dao import OrderDao
from apps.system.lessee.dao import LesseeDao
from apps.pay.recordIncomes.dao import RecordIncomesDao
from apps.system.payway.dao import PaywayDao


class CheckData:
        
    def handle(self):
        # 检查在线销售的商品销售价和成本价是否有为0的
        _skus = SkuDao().findAll().filter(item__status=1, item__is_delete=False)
        for sku in _skus.filter(Q(sellingPrice__lte=0)|Q(costPrice__lte=0)):
            print('商品', sku.item, '的销售价和成本价有为0的')
        for sku in _skus.filter(coverUrl=''):
            print('商品', sku.item, '的封面图缺失')
            # sku.coverUrl = json.loads(sku.item.coverPhotos)[0] if len(json.loads(sku.item.coverPhotos)) else ''
            # sku.save()
